/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.apt.servelet;

import com.apt.tag.Connect_DB;
import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.util.Calendar;

/**
 *
 * @author Lambach
 */
public class Enable_User_DB {

    public static boolean setEnable(String userId) {
        String up = " UPDATE [Matrimony].[dbo].[Accounts] SET [Account_Status] = 1,[Date_Expired]=? WHERE [Account_Id]=?";
        boolean re = false;
        Connection con = null;
        PreparedStatement ps = null;
        Calendar c = Calendar.getInstance();
        c.set(Calendar.YEAR, c.get(1) + 1);

        try {
            con = Connect_DB.getConnection();
            ps = con.prepareStatement(up);
            ps.setDate(1, new Date(c.getTimeInMillis()));
            ps.setInt(2, new Integer(userId));
            int i = ps.executeUpdate();
            if (i > 0) {
                re = true;
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            Connect_DB.close(null, null, ps, con);
        }
        return re;
    }
}
